<!DOCTYPE html>
<head>
    <meta name="_token" content="{!! csrf_token() !!}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
</head>
<body>
    <button id="pay-btn" style="height:50px;width:100%;">微信支付</button>
</body>
</html>
<script src="/js_system/jquery.min.js"></script>

<script>
    $('#pay-btn').click(function(){
        //获取支付数据
        //var url = "{{url('/api/v4/weixin/getPayData')}}";
        var url = "http://wx.laohoulundao.com/api/v4/weixin/getPayData";
        var data = {
            mobile:"{{$data->UserName}}",
            key:"{{$data->AppKey}}",
            goodsType:"live_{{$data->liveId}}",
            goodsId:4,
            goodsNumber:1
        };

        var payData = {};
        $.ajax({
            url:url,
            type:'post',
            data:data,
            async:false,
            success:function(res)
            {
                payData = res;
            }
        })

        payData = payData.data;
        if("undefined" != typeof android)
        {
            payData = JSON.stringify(payData);
            android.weChatPay(payData);
        }
        else if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.weChatPay)
        {
            //alert(window.webkit);
            //alert(window.webkit.messageHandlers);
            window.webkit.messageHandlers.weChatPay.postMessage(payData);
        }
        else
        {
            console.log(payData);
        }
    });
</script>